package boerseTest.mainTest.AssetsTest;

import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;

import boerse.main.Asset.Share;
import boerse.main.Asset.ShareItem;
import boerse.main.Exceptions.NegativeShareCountException;


public class ShareItemTest {

	private ShareItem shareItem;
	
	@Before
	public void setUp() {		
		shareItem = new ShareItem(4, new Share("testShare", 100));
				
	}

	
	@Test
	public void testAddShare() {
		shareItem.addShare(3);
		assertEquals("4 Shares plus 3 Shares are 5 Shares", 7, shareItem.getQuantity());	
	}
	
	
	@Test
	public void testDeterminePrice() {	
		assertEquals("Ammount of Cash should be 1000 cent", 4*100, shareItem.determinePrice());
	}
	
	
	@Test
	public void testRemoveShare() throws NegativeShareCountException {
		shareItem.removeShare(3l);
		
		assertEquals("4 shares minus 3 shares is 1 shares", 1, shareItem.getQuantity());
	}
	
	
	@Test(expected = NegativeShareCountException.class)
	public void testRemoveShareNegativeShareCountException() throws NegativeShareCountException {
		shareItem.removeShare(6l);
	}
}
